#define _CRT_SECURE_NO_WARNINGS
#include <conio.h> 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h> 

void inputString(const char * prompt, char * input)

{
	input[0] = 0;
	printf("%s", prompt);
	scanf("%[^\n]", input);
	fflush(stdin);
}

int main(int argc, char *argv[])
{
	if ( argc != 3)
	{
		printf("Error, wrong arguments. Use <>.exe input.c output.c\n");
	}
		
	int dlprv=0;
	char  line[1000];


	FILE * inFile;
	FILE * outFile;

	//inputString("input file name: ", line);
	inFile = fopen(argv[1], "r");
	if (inFile == NULL)
	{
		printf("Error, couldn't opened file\n");
	}
	outFile = fopen(argv[2], "w");

	while (1)
	{
		int c = fgetc(inFile);
		if (c == EOF)
		{
			break;
		}
		if (c == '/')
		{
			c = fgetc(inFile);
			if (c == '/')
			{
				while (1)
				{
					c = fgetc(inFile);
					if (c == EOF)
					{
						dlprv=1;
						break;
					}
					if (c == '\n')
					{
						fputc ('\n', outFile );
						break;
					}
				}
			}
			else
			{
				if (c == '*')
				{
					while (1)
					{
						c = fgetc(inFile);
						if (c == EOF)
						{
							dlprv=1;
							break;
						}
						if (c == '/')
						{
							c=fgetc(inFile);
							if (c == '*')
							{
								dlprv=1;
								break;
							}
						}
						if (c == '*')
						{
							c = fgetc(inFile);
							if (c == '/')
							{
								break;
							}
						}
					}
				}
				else
				{
					fputc ('/', outFile );
					fputc( c, outFile );
				}

			}

		}
		else
		{
			fputc( c, outFile );
		}
		if (dlprv == 1)
		{
			printf("error\n");
			_unlink(argv[2]);
			break;
		}



	}
	printf("vse zakonchilos\n");



	fclose(inFile);
	fclose(outFile);
	system ("PAUSE");
}